#include<iostream>
#include<queue>
using namespace std;
int main()
{
	int t, p, n;
	cin >> t;
	while (t--) {
		cin >> p >> n;
		priority_queue<int>down;
		priority_queue<int, vector<int>, greater<int>>up;
		cout << p << " " << (n + 1) / 2 << endl;
		int cnt = 0;
		for (int i = 1; i <= n; i++) {
			int x;
			cin >> x;
			if (down.empty() || x <= down.top()) down.push(x);
			else up.push(x);
			if (down.size() > up.size() + 1) {
				up.push(down.top());
				down.pop();
			}
			if (up.size() > down.size()) {
				down.push(up.top());
				up.pop();
			}
			if (i & 1) {
				cout << down.top() << " ";
				if (++cnt % 10 == 0) cout << endl;
			}
		}
		if (cnt % 10) cout << endl;
	}
	return 0;
}